package com.ruoyi.user.controller.app;


import com.ruoyi.common.core.constant.constant.PathConstant;
import com.ruoyi.common.core.context.SecurityContextHolder;
import com.ruoyi.common.core.pojo.vo.SingleVO;
import com.ruoyi.common.core.result.Result;
import com.ruoyi.system.api.model.request.AppUserBalanceBatchOpetRequest;
import com.ruoyi.system.api.model.request.AppUserBalanceOpetRequest;
import com.ruoyi.user.model.pojo.result.app.AppUserBalanceResult;
import com.ruoyi.user.service.IBalanceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Tag(name = "App-用户余额相关", description = "App-用户余额相关")
@RestController
@RequestMapping(PathConstant.APP_PATH + "user-balance")
public class AppUserBalanceController {
    @Autowired
    private IBalanceService iBalanceService;

    @Operation(summary = "内部调用扣减余额相关", description = "内部调用扣减余额相关")
    @PostMapping("docBalance")
    public SingleVO<Boolean> docBalance(@RequestBody AppUserBalanceOpetRequest request) {
        return Result.single(iBalanceService.docBalance(request.getUserId(), request.getType(), request.getContent(), request.getBalTypel(), request.getMoney()));
    }

    @Operation(summary = "内部调用增加余额相关", description = "内部调用增加余额相关")
    @PostMapping("aocBalance")
    public SingleVO<Boolean> aocBalance(@RequestBody AppUserBalanceOpetRequest request) {
        return Result.single(iBalanceService.aocBalance(request.getUserId(), request.getType(), request.getContent(), request.getBalTypel(), request.getMoney()));
    }


    @Operation(summary = "批量内部调用增加余额相关", description = "批量内部调用增加余额相关")
    @PostMapping("aocBalanceByBatch")
    public SingleVO<Boolean> aocBalanceByBatch(@RequestBody AppUserBalanceBatchOpetRequest request) {
        return Result.single(iBalanceService.aocBalanceBatch(request.getRequests(), request.getType(), request.getContent(), request.getBalTypel()));
    }

    @Operation(summary = "获取钻石", description = "获取钻石")
    @GetMapping("balance")
    public SingleVO<AppUserBalanceResult> balance() {
        return Result.single(iBalanceService.balance(SecurityContextHolder.getUserId()));
    }


}

